﻿using Authorization.Center.Dto;
using MediatR;
using S.PurchaseAndSales.Api.Application.Command.PurchaseFormCommand;
using S.PurchaseAndSales.Domain.Model;
using S.PurchaseAndSales.Infrastructure.Interface.PurchaseForm;

namespace S.PurchaseAndSales.Api.Application.CommandHandlers.PurchaseFormHandler
{
    /// <summary>
    /// 财务审核
    /// </summary>
    public class PurchaseFormAuditCommandHandler : IRequestHandler<PurchaseFormAuditCommand, bool>
    {
        #region 注入
        private readonly IPurchaseFormRepository repository;

        public PurchaseFormAuditCommandHandler(IPurchaseFormRepository repository)
        {
            this.repository = repository;
        }

        #endregion
        public async Task<bool> Handle(PurchaseFormAuditCommand request, CancellationToken cancellationToken)
        {
            //要审核数据的id
            int[] ids=request.PurchaseFormIds.Split(',').Select(int.Parse).ToArray();
            //查询符合的数据
            return await repository.AuditPurchaseFormByIds(ids,request.UpdateBy); 

        }
    }
}
